package com.woniu.util;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * 过滤器注册配置类
 *
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/8/26 16:06
 */
@Configuration
public class FilterRegister {
    @Bean
    public FilterRegistrationBean<TimeCountFilter> filterFilterRegistrationBean() {
        FilterRegistrationBean<TimeCountFilter> frb = new FilterRegistrationBean<>();
        //将我们创建的过滤器添加进注册器中
        frb.setFilter(new TimeCountFilter());
        //配置拦截的url
        frb.addUrlPatterns("/*");
        //设置优先级，数值越小越高
        frb.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return frb;
    }
}
